# Contributor: Roberto Oliveira <robertoguimaraes8@gmail.com>
# Maintainer: Patrycja Rosa <alpine@ptrcnull.me>
pkgname=gradle
pkgver=8.10.2
pkgrel=0
pkgdesc="Build tool with a focus on build automation and support for multi-language development"
url="https://gradle.org/"
arch="noarch"
options="!check"
license="Apache-2.0"
source="https://services.gradle.org/distributions/gradle-$pkgver-bin.zip"

# highest supported version in community
case "$CARCH" in
arm* | x86)
	depends="openjdk8"
	;;
*)
	depends="openjdk21"
	;;
esac

# secfixes:
#   7.6.1-r0:
#     - CVE-2023-26053
#   7.2-r0:
#     - CVE-2021-32751
#   6.8.3-r0:
#     - CVE-2020-11979

package() {
	local gradlehome="/usr/share/java/$pkgname"
	local destdir="$pkgdir/$gradlehome"

	install -dm755 "$destdir"/bin
	rm bin/*.bat
	install -m755 bin/* "$destdir"/bin

	install -dm755 "$pkgdir"/usr/bin
	ln -sf $gradlehome/bin/gradle "$pkgdir"/usr/bin/gradle

	install -dm755 "$destdir"/lib
	cp -a lib "$destdir"/

	# NOTICE file should be redistributed for derivative works
	local file; for file in LICENSE NOTICE; do
		install -m644 -D $file "$pkgdir"/usr/share/licenses/$pkgname/$file
	done
}

sha512sums="
c48d4b7f4a7b6aa4886848ce913b099b8b7f2494b3d0ca86a21588f6482a185265fffeb0bb6da5f52b8c5f958e589d3a8be9c7fd846790ffbe12be1ad05c9f4f  gradle-8.10.2-bin.zip
"
